package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	sprime
*/
public class sprime {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("sprime.in"));
		ArrayList<Integer> res = new sprime().solve(f);
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"sprime.out")));
		for (int i : res) out.println(i);
		out.close();
		System.exit(0);
	}
	
	private ArrayList<Integer> solve(BufferedReader f) throws IOException {
		ArrayList<Integer> list = new ArrayList<Integer>();
		int N = read(f);
		search(N, 0, list);
		return list;
	}
	
	private void search(int N, int value, ArrayList<Integer> list) {
		if (N == 0) {
			list.add(value);
			return;
		}
		for (int i=1; i<10; i++) {
			int next = value*10 + i;
			if (!isPrime(next)) continue;
			search(N-1, next, list);
		}
	}
	
	public boolean isPrime(int N) {
		if (N == 1) return false;
		for (int i=2; i*i<=N; i++) {
			if (N%i == 0) return false;
		}
		return true;
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
}